package com.astar.service.impl;

import com.astar.entity.CustomMenu;
import com.astar.entity.Menu;
import com.astar.mapper.MenuMapper;
import com.astar.service.IMenuService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 菜单权限表 服务实现类
 * </p>
 *
 * @author jobob
 * @since 2020-01-17
 */
@Service
public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements IMenuService {

    @Autowired
    private MenuMapper menuMapper;

    @Autowired
    private IMenuService menuServiceImpl;


    @Override
    public List<Menu> selectAll() {
        return menuMapper.selectAll();
    }

    @Override
    public Menu selectOne(Integer id) {
        return menuMapper.selectOneById(id);
    }

    @Override
    public CustomMenu selectOne1(Integer id) {
        return menuMapper.selectOne1(id);
    }


    @Override
    public List<CustomMenu> selectChile(Integer parentId) {
        return menuMapper.selectChile(parentId);
    }

    @Override
    public int insert(Menu menu) {
        Menu menu1 = menuServiceImpl.selectOne(menu.getParentId());

        return menuMapper.insert(menu);
    }

    @Override
    public List<CustomMenu> selectMenus() {
        return menuMapper.selectMenus();
    }

    @Override
    public int update(Menu menu) {
        return menuMapper.updateById(menu);
    }
}
